package com.tony.boot.resolver;

import com.coxautodev.graphql.tools.GraphQLResolver;
import com.tony.boot.entity.Author;
import com.tony.boot.entity.Book;
import com.tony.boot.repository.BookRepository;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Set;

public class AuthorResolver implements GraphQLResolver<Author> {
    @Autowired
    private BookRepository bookRepository;

    public AuthorResolver(BookRepository bookRepository) {
        this.bookRepository = bookRepository;
    }

    public Set<Book> getBooks(Author author){
        return author.getBooks();
    }
}
